//
//  TMTVInfoPlayVC.swift
//  MoviesInfo
//
//  Created by zhangkai on 2023/5/1.
//  Copyright © 2023 Tobias Ruano. All rights reserved.
//

import UIKit
import BMPlayer

class TMTVInfoPlayVC: UIView {
    var player:BMPlayer!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        
        player = BMPlayer()
        addSubview(player)
        player.snp.makeConstraints { (make) in
            make.top.equalTo(self).offset(0)
            make.left.right.equalTo(self)
            // Note here, the aspect ratio 16:9 priority is lower than 1000 on the line, because the 4S iPhone aspect ratio is not 16:9
            make.height.equalTo(player.snp.width).multipliedBy(9.0/16.0).priority(750)
        }
        // Back button event
//        player.backBlock = { [unowned self] (isFullScreen) in
//            if isFullScreen == true { return }
//            let _ = self.navigationController?.popViewController(animated: true)
//        }
//
        
        let asset = BMPlayerResource(url: URL(string: "https://www.apple.com/105/media/cn/mac/family/2018/46c4b917_abfd_45a3_9b51_4e3054191797/films/bruce/mac-bruce-tpl-cn-2018_1280x720h.mp4")!,
                                     name: "风格互换：原来你我相爱")
        player.setVideo(resource: asset)
        
        player.playTimeDidChange = { time,time1 in
            print("懂了\(time)")
            
        }
        player.newplayTimeDidChange = { time,time1 in
            print("懂了啊\(time)")
        }
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
